/**
 * Created by heshufen on 20/6/28.
 */
import React from 'react';
import {Text, TouchableOpacity, View} from 'react-native';
import Horizontal from '../Horizontal';

export default class CommonDialogWithoutContent extends React.Component {
    render() {
        const {visible, containerStyle, cancelStyle, confirmStyle, confirmText, cancelText, onCancel, onConfirm, contentView} = this.props;
        if (visible) {
            return <View style={styles.wrapper}>
                <View style={containerStyle || styles.container}>
                    {contentView}
                    <Horizontal style={styles.btnsContainer}>
                        <TouchableOpacity style={styles.btn} onPress={onCancel}>
                            <Text style={cancelStyle || styles.cancelBtnText}>{cancelText || '取消'}</Text>
                        </TouchableOpacity>
                        <TouchableOpacity style={[styles.btn, styles.last]} onPress={onConfirm}>
                            <Text style={confirmStyle || styles.confirmBtnText}>
                                {confirmText || '确定'}
                            </Text>
                        </TouchableOpacity>
                    </Horizontal>
                </View>
            </View>;
        }
        return <View/>;
    }
}


const styles = {
    wrapper: {
        position: 'absolute',
        top: 0,
        left: 0,
        bottom: 0,
        right: 0,
        backgroundColor: 'rgba(0,0,0,0.70)',
        alignItems: 'center',
        justifyContent: 'center',
    },
    container: {
        width: 271,
        borderRadius: 8,
        backgroundColor: '#fefffe',
    },
    btnsContainer: {
        borderTopWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
        // borderColor: '#eaeaea',
    },
    btn: {
        height: 48,
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        borderRightWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
    },
    cancelBtnText: {
        fontFamily: 'PingFang-SC-Medium',
        fontSize: 15,
        color: '#3e72fe',
    },
    confirmBtnText: {
        fontFamily: 'PingFang-SC-Medium',
        fontSize: 15,
        color: '#3e72fe',
    },
    last: {
        borderRightWidth: 0
    },
};
